package day06_exception_collection.com.itheima.d5_list;

import java.util.ArrayList;
import java.util.Iterator;

public class ListDemo2 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("java");
        list.add("宁夏枸杞");
        list.add("黑枸杞");
        System.out.println("list = " + list);

        for (int i = 0; i < list.size(); i++) {
            System.out.println("list.get("+ i + ") = " + list.get(i));
        }
        Iterator<String> it = list.iterator();
        while (it.hasNext()){
            String ele = it.next();
            System.out.println("ele = " + ele);
        }
        for (String s : list) {
            System.out.println("s = " + s);
        }
        list.forEach(s -> System.out.println("s = " + s));
    }
}
